<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>权限</title>
        <script src="/jquery/jquery-3.2.1.min.js"></script>
        <link rel="stylesheet" href="/layui/css/layui.css">
        <script src="/layui/layui.js"></script>
        <style>
            *{
                padding: 0;
                margin: 0;
            }
            body{
                background-color:rgb(243,243,243);
            }
            .box{
                width: 100%;
                margin: 0 auto;
                padding-top: 10px;
            }
            #checkboxBox{
                width: 400px;
            }
            img{
                width: 100px;
                height: 100px;
                cursor: pointer;
            }

        </style>
    </head>
    <body>
        <div class="box">
            <form class="layui-form">
                <div class="layui-form-item" style="margin-top: 20px">
                    <label class="layui-form-label">用户名：</label>
                    <div class="layui-input-inline" style="width: 500px">
                        <input type="text" name="trueName" disabled id="trueName" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">拥有权限：</label>
                    <div class="layui-input-inline">
                        <div id="checkboxBox">
                            <input type="checkbox" value="1" name="authorityId" title="管理员" lay-skin="primary" >
                            <input type="checkbox" value="2" name="authorityId" title="教师" lay-skin="primary">
                            <input type="checkbox" value="3" name="authorityId" title="运营" lay-skin="primary" >
                            <input type="checkbox" value="4" name="authorityId" title="人事" lay-skin="primary" >
                        </div>
                    </div>
                </div>
                <div class="layui-input-inline">
                    <label class="layui-form-label">用户描述：</label>
                    <div class="layui-input-inline">
                        <textarea  style="resize:none;width: 500px;" id="remark" name="remark" disabled class="layui-textarea" ></textarea>
                    </div>
                </div>
            </form>
        </div>
    </body>
    <script>
        layui.use(['jquery','layer','upload','laydate','form'],function(){
            var $=layui.jquery;
            var laydate=layui.laydate;
            var form=layui.form;

            var checkbox=$("input[name='authorityId']");

            $.ajax({
                url:"/login/getJsUserPower",
                data:{'userId':localStorage.getItem("userId")},
                type:'post',
                dataType:'json',
                success:function (data) {
                    for(var i=0;i<data.data.length;i++){
                        for(var j=0;j<checkbox.length;j++){
                            if(checkbox[j].value==data.data[i]){
                                checkbox[j].checked = true;
                            }
                        }
                    }
                    form.render();
                }
            })


        })
    </script>
</html>